package com.xdf.docmanagementsystem.service.impl;

import com.xdf.docmanagementsystem.common.util.Example;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.xdf.docmanagementsystem.entity.SysUser;

import java.util.List;

import com.xdf.docmanagementsystem.dao.SysUserMapper;
import com.xdf.docmanagementsystem.service.SysUserService;

/**
 * @Description : com.xdf.docmanagementsystem.service.impl(业务层实现类,该类为生成器自动生成).
 * @Author : ZK
 * @Date : 2020-06-26 08:44:23
 */
@Service
public class SysUserServiceImpl implements SysUserService {
    @Autowired
    private SysUserMapper dao;

    /**
     * @Describe 新增方法
     * @author ZK
     * @Date 2020-06-26 08:44:23
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insert(SysUser record) throws Exception {
        return dao.insert(record);
    }

    /**
     * @Describe 选择新增
     * @author ZK
     * @Date 2020-06-26 08:44:23
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insertSelective(SysUser record) throws Exception {
        return dao.insertSelective(record);
    }

    /**
     * @Describe 批量新增
     * @author ZK
     * @Date 2020-06-26 08:44:23
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int multiInsert(List<SysUser> list) throws Exception {
        return dao.multiInsert(list);
    }

    /**
     * @Describe 修改
     * @author ZK
     * @Date 2020-06-26 08:44:23
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int updateByPrimaryKey(SysUser record) throws Exception {
        return dao.updateByPrimaryKey(record);
    }

    /**
     * @Describe 选择修改
     * @author ZK
     * @Date 2020-06-26 08:44:23
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int updateByPrimaryKeySelective(SysUser record) throws Exception {
        return dao.updateByPrimaryKeySelective(record);
    }

    /**
     * @Describe 修改
     * @author ZK
     * @Date 2020-06-26 08:44:23
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int update(SysUser record) throws Exception {
        return dao.updateByPrimaryKey(record);
    }

    /**
     * @Describe 批量修改
     * @author ZK
     * @Date 2020-06-26 08:44:23
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int multiUpdate(List<SysUser> list) throws Exception {
        return dao.multiUpdate(list);
    }

    /**
     * @Describe 根据主键查询
     * @author ZK
     * @Date 2020-06-26 08:44:23
     */
    @Override
    public SysUser selectByPrimaryKey(Integer id) throws Exception {
        return dao.selectByPrimaryKey(id);
    }

    /**
     * @Describe 根据主键删除
     * @author ZK
     * @Date 2020-06-26 08:44:23
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deleteByPrimaryKey(Integer id) throws Exception {
        return dao.deleteByPrimaryKey(id);
    }

    /**
     * @Describe 根据Entity查询
     * @author ZK
     * @Date 2020-06-26 08:44:23
     */
    @Override
    public List<SysUser> listQuery(SysUser record) throws Exception {
        return dao.selectByParam(record);
    }

    /**
     * 根据账号查询
     *
     * @param account
     * @return
     * @throws Exception
     */
    @Override
    public SysUser selectByUserAccount(String account) throws Exception {
        List<SysUser> list = dao.selectByExample(new Example().andEq("user_account", account));
        if (list != null && list.size() > 0) return list.get(0);
        return null;
    }

}